/**
  实习报名审核
*/
<template>
    <div>
        <condition-card
            @reset="reset"
            @search="onSubmit"
            label-position="right"
            label-width="150px"
        >
            <el-row :gutter="24" style="height: 50px;">
                <el-col :span="8">
                    <el-form-item :label="$t('registrationReview.practiceBase')">
                        <el-input v-model="queryForm.condition.baseName"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item :label="$t('registrationReview.college')">
                        <DictSelect
                            v-model="queryForm.condition.collegeAcademy"
                            filterable
                            @change="collegeChange"
                            :data="options.title"
                            :plzSelect="true"
                        ></DictSelect>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item :label="$t('registrationReview.profession')">
                        <el-select
                            collapse-tags
                            v-model="queryForm.condition.majorList"
                            multiple
                            filterable
                            clearable
                            style="width: 100%"
                        >
                            <el-option
                                v-for="item in options.profession"
                                :key="item.code"
                                :label="item.name"
                                :value="item.code"
                            ></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item :label="$t('registrationReview.status')">
                        <el-select
                            v-model="queryForm.condition.status"
                            clearable
                            style="width: 100%"
                        >
                            <el-option
                                v-for="item in statusList"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value"
                            ></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <!-- <el-form-item :label="$t('graduate.college')"> -->
                    <el-form-item :label="$t('registrationReview.workplace')">
                        <el-input v-model="queryForm.condition.workAddress"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item></el-form-item>
                </el-col>

                <el-col :span="8">
                    <!-- <el-form-item :label="$t('internship.effectiveDate')" size="small" > -->
                    <el-form-item :label="$t('registrationReview.declarati')" size="small">
                        <el-date-picker
                            :placeholder="$t('internship.pleaseSelect')"
                            style="width: 100%"
                            v-model="queryForm.condition.applyTimeStart"
                            :picker-options="pickerOptionsStart"
                            type="date"
                            value-format="yyyy-MM-dd"
                            format="yyyy-MM-dd"
                        ></el-date-picker>
                    </el-form-item>
                    <!--  -->
                </el-col>
                <el-col :span="8">
                    <!-- <el-form-item :label="$t('internship.effectiveEnd')" size="small"> -->
                    <el-form-item :label="$t('registrationReview.reporti')" size="small">
                        <el-date-picker
                            :placeholder="$t('internship.pleaseSelect')"
                            style="width: 100%"
                            v-model="queryForm.condition.applyTimeEnd"
                            :picker-options="pickerOptionsEnd"
                            type="date"
                            value-format="yyyy-MM-dd"
                            format="yyyy-MM-dd"
                        ></el-date-picker>
                    </el-form-item>
                </el-col>
                <!--  -->
            </el-row>
        </condition-card>
        <el-card shadow="never" v-loading="loading" body-style="padding: 24px;" class="card-margin">
            <h1 class="condition-title">{{$t('registrationReview.enrollmentReviewList')}}</h1>
            <div class="float-left associated-conditional-input">
                <KeywordInput
                    v-model="queryForm.condition.student "
                    :placeholder="$t('internProgress.pleasesSearch')"
                    @enter="onSubmit"
                />
            </div>
            <div class="edu-opertion-bar sub-title">
                <div class="float-right" style="display: flex;">
                    <el-upload
                        class="upload-demo"
                        action="/api/practiceservice/specialist/import"
                        :auto-upload="true"
                        style="display: none;"
                    >
                        <span slot="trigger" ref="importBtn">{{$t('registrationReview.export')}}</span>
                    </el-upload>
                    <el-button
                        style="margin-left:10px"
                        type="primary"
                        @click="exportFile"
                    >{{$t('internship.derive')}}</el-button>
                    <el-button
                        @click="regDownload"
                        type="primary"
                    >{{$t('registrationReview.downloadSchedule')}}</el-button>
                </div>
            </div>
            <edu-table
                :pagination="false"
                :order="false"
                :tooltipEffect="tooltipEffect"
                stripe
                :data="dataList"
                size="mini"
                @selection-change="handleSelectionChange"
            >
                <edu-table-column label="学号" prop="studentId"></edu-table-column>
                <edu-table-column label="学生姓名" prop="studentName"></edu-table-column>
                <edu-table-column :label="$t('requirement.college')" prop="faculty">
                    <template
                        slot-scope="scope"
                    >{{scope.row.faculty | collegeAcademyList(options.title)}}</template>
                </edu-table-column>
                <edu-table-column :label="$t('requirement.major')" prop="profession">
                    <template
                        slot-scope="scope"
                    >{{scope.row.profession | collegeAcademy(options.faculty)}}</template>
                </edu-table-column>
                <edu-table-column label="实习单位名称" prop="baseName" min-width="120"></edu-table-column>
                <edu-table-column label="岗位名称" prop="positionName"></edu-table-column>
                <edu-table-column label="岗位人数" prop="personNum"></edu-table-column>
                <edu-table-column label="工作地点" prop="workAddress"></edu-table-column>
                <edu-table-column label="待遇" prop="treatment"></edu-table-column>
                <edu-table-column :label="$t('registrationReview.workDate')" prop="workTimeStart">
                    <template slot-scope="props">
                        <span>{{ props.row.workTimeStart+'/'+props.row.workTimeEnd }}</span>
                    </template>
                </edu-table-column>
                <edu-table-column :label="$t('registrationReview.theTime')" prop="applyTimeStart">
                    <template slot-scope="props">
                        <span>{{ props.row.applyTimeStart+'/'+props.row.applyTimeEnd }}</span>
                    </template>
                </edu-table-column>
                <!-- <edu-table-column :label="$t('internship.introduc')" prop="introduction"></edu-table-column> -->
                <!-- <edu-table-column :label="$t('internship.currentStatus')" prop="status"> -->
                <edu-table-column label="当前状态" prop="status">
                    <template slot-scope="props">
                        <!-- <span v-if="props.row.status == 1">导师审核</span>
                        <span v-if="props.row.status == 2">基地审核</span>
                        <span v-if="props.row.status == 3">已审核</span>
                        <span v-if="props.row.status == 4">已驳回</span>
                        <span v-if="props.row.status == 5">已撤销</span>-->
                        {{props.row.status | collegeAcademyList(statusList)}}
                    </template>
                </edu-table-column>
                <edu-table-column :label="$t('graduate.operate')" fit width="260">
                    <template slot-scope="props">
                        <el-button
                            v-if="revokeBtn &&props.row.status == 1 && personas=='教务员'||props.row.status == 1&&personas=='学生'"
                            type="text"
                            size="mini"
                            @click="deleteBaseAssessSet(props.row)"
                        >撤销</el-button>
                        <el-button
                            type="text"
                            v-if="auditBut &&personas=='导师'&& props.row.status==1"
                            @click="checkOutlines(props.row)"
                        >{{$t('internship.check')}}</el-button>
                        <el-button
                            type="text"
                            v-if="auditBut && personas=='基地管理员'&& props.row.status==2"
                            @click="checkOutlines2(props.row)"
                        >{{$t('internship.check')}}</el-button>
                        <el-button
                            type="text"
                            @click="view(props.row)"
                        >{{$t('requirement.details')}}</el-button>
                        <!-- <el-button
              v-if="detailsBut"
              type="text"
              @click="detailsOutline(props.row)"
                        >{{$t('graduate.details')}}</el-button>-->
                    </template>
                </edu-table-column>
            </edu-table>
            <el-row type="flex" class="row-bg" justify="end">
                <el-col>
                    <el-pagination
                        @size-change="handleSizeChange"
                        @current-change="handleCurrentChange"
                        :current-page="queryForm.pageNum_"
                        :page-sizes="[20, 40, 80, 100]"
                        :page-size="queryForm.pageSize_"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="queryForm.total_"
                        style="float:right;margin-top:10px"
                    ></el-pagination>
                </el-col>
            </el-row>
        </el-card>
        <el-dialog
            @close="dataObjit={}"
            :before-close="beforeClose"
            :title="title"
            width="70%"
            :visible.sync="addflag"
            :show-close="beforeClose"
        ></el-dialog>
        <el-dialog
            :before-close="cancelClose"
            :title="$t('internship.batchReview')"
            width="70%"
            :visible.sync="dialogFormVisible"
            :show-close="cancelClose"
        >
            <!-- batchReviewClose -->
            <el-form :model="form">
                <el-form-item :label="$t('internship.auditOpinion')">
                    <el-input v-model="form.content" type="textarea" :rows="5" maxlength="325"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="cancelClose">{{$t('graduate.cancel')}}</el-button>
                <el-button type="danger" @click="reject">{{$t('identificationToDoList.Reject')}}</el-button>
                <el-button type="primary" @click="pass">{{$t('identificationToDoList.adopt')}}</el-button>
            </div>
        </el-dialog>
        <edu-export-dialog
            :disabled="exportButton"
            :title="$t('message.prompt')"
            ref="downloadRef"
            :data="exportResult"
        ></edu-export-dialog>
    </div>
</template>
<script>
import { queryDic } from 'common/src/api/dictionary'
import UTILS from 'common/src/utils/utils'
import graduateStudent from 'common/src/api/graduateStudent/graduateStudent'
import SelectTree2 from 'common/src/views/graduateStudent/component/SelectTree2'
import filters from 'common/src/filters'
import innovativeApi from 'common/src/api/innovative/innovative'
import graduateStudentApi from 'common/src/api/graduateStudent/graduateStudent'
export default {
    components: {
        SelectTree2
    },
    data() {
        return {
            indexKey: '1', // 面包屑
            userInfo: {},
            allCollege: [],
            title: '',
            category: { category: 1 },
            mainbase: '专家',
            showDate: true,
            dialogFormVisible: false,
            addflag: false,
            tableFlag: false,
            editflag: false,
            editProp: '',
            dataEdit: {},
            tableObjit: {},
            databjit: [],
            peopleadd: {},
            curRow: {},
            form: {
                content: ''
            },
            ifDetials: false,
            copyDialog: false,
            curCalendarId: '',
            isAllDel: true,
            exportButton: false,
            exportResult: null,
            checkTopicListForm: {
                dataList: []
            },
            multipleSelection: [],
            provideData: {}, // 提供子组件表格数据
            queryForm: {
                pageNum_: 1,
                pageSize_: 20,
                total_: 0,
                condition: {
                    baseName: '',
                    collegeAcademyList: [],
                    majorList: [],
                    applyTimeStart: '',
                    applyTimeEnd: '',
                    student: ''
                }
            },
            dataListProp: {},
            dataProp: '',
            copyTime: {
                time: ''
            },
            options: {
                majorList: [],
                faculty: [],
                title: [],
                sex: [],
                profession: []
            },
            statusList: [
                {
                    label: '导师审核',
                    value: 1
                },
                {
                    label: '基地审核',
                    value: 2
                },
                {
                    label: '已审核',
                    value: 3
                },
                {
                    label: '已驳回',
                    value: 4
                },
                {
                    label: '已撤销',
                    value: 5
                }
            ],
            pickerOptionsStart: {
                disabledDate: time => {
                    let endDateVal = this.queryForm.condition.applyTimeEnd
                    if (endDateVal) {
                        return time.getTime() > new Date(endDateVal).getTime()
                    }
                }
            },
            pickerOptionsEnd: {
                disabledDate: time => {
                    let beginDateVal = this.queryForm.condition.applyTimeStart
                    if (beginDateVal) {
                        return time.getTime() <= new Date(beginDateVal).getTime() - 86400000
                    }
                }
            },
            queryList: {
                calendarId: '',
                faculty: '',
                status: '',
                course: ''
            },
            rules: {},
            auths: [],
            rulesForm: {},
            dataList: [],
            revokeBtn: true, // 撤销
            addBut: false,
            editBut: false,
            detailsBut: false,
            deriveBut: false,
            leadBut: false,
            auditBut: true,
            removeBut: false,
            batchReviewBut: false,
            startUsingBut: false,
            blockUpBut: false,
            breadPath: {
                label: this.$t('graduate.graduate'),
                key: '1',
                children: [
                    {
                        key: '2',
                        label: ''
                    }
                ]
            }
        }
    },
    watch: {
        auths: {
            handler: function(value) {
                this.auths.some(item => {
                    if (item.authCode === 'settingInternshipBase-revokeBtn') {
                        // 撤销
                        this.revokeBtn = true
                    }
                    if (item.authCode === 'settingInternshipBase-addBut') {
                        // 新增
                        this.addBut = true
                    }
                    if (item.authCode === 'settingInternshipBase-editBut') {
                        // 编辑
                        this.editBut = true
                    }
                    if (item.authCode === 'settingInternshipBase-detailsBut') {
                        // 详情
                        this.detailsBut = true
                    }
                    if (item.authCode === 'settingInternshipBase-deriveBut') {
                        // 导出
                        this.deriveBut = true
                    }
                    if (item.authCode === 'settingInternshipBase-leadBut') {
                        // 导入
                        this.leadBut = true
                    }
                    if (item.authCode === 'settingInternshipBase-auditBut') {
                        // 审核
                        this.auditBut = true
                    }
                    if (item.authCode === 'settingInternshipBase-removeBut') {
                        // 删除
                        this.removeBut = true
                    }
                    if (item.authCode === 'settingInternshipBase-batchReviewBut') {
                        // 批量审核
                        this.batchReviewBut = true
                    }
                    if (item.authCode === 'settingInternshipBase-startUsingBut') {
                        // 启用
                        this.startUsingBut = true
                    }
                    if (item.authCode === 'settingInternshipBase-blockUpBut') {
                        // 停用
                        this.blockUpBut = true
                    }
                })
            },
            deep: true
        }
    },
    filters: {
        collegeAcademyList(val, array) {
            let str = ''
            for (let item of array) {
                if (val == item.value) {
                    str = item.label
                }
            }
            return str
        },
        collegeAcademy(val, array) {
            let list = []
            let str = []
            if (val) {
                list = val.split(',')
                list.forEach(el => {
                    array.forEach(ele => {
                        if (el == ele.value) {
                            str.push(ele.label)
                        }
                    })
                })
                return str.join()
            }
        },

        isEnabled(val) {
            switch (val) {
                case 0:
                    return '停用'
                case 1:
                    return '启用'
                default:
                    return val
            }
        }
    },
    async created() {
        this.getOptions() // 获取字典
        this.postRegistration(this.queryForm)
        this.getCurrentRole()
        this.auths = JSON.parse(localStorage.getItem('sessiondata')).auths
        // 获取学院innerRoles为1--管理员，innerRoles为2--教务员
        // 登录用户如果是学院教务员，就获取当前用户的管理学院或者所属学院,innerRoles为1
        // 登录用户如果是学校管理员，就获取字典接口（所有学院）
        // 登录用户如果是学院管理员又是学院教务员，就获取字典接口（所有学院）
        this.userInfo = JSON.parse(localStorage.getItem('user'))
        if (
            (this.userInfo.innerRoles.indexOf('1') > -1 &&
                this.userInfo.innerRoles.indexOf('2') > -1) ||
            this.userInfo.innerRoles.indexOf('1') > -1
        ) {
            this.options.collegeAcademyList = this.allCollege
        } else if (this.userInfo.innerRoles.indexOf('2') > -1) {
            this.options.collegeAcademyList = [
                {
                    value: this.userInfo.faculty,
                    label: this.userInfo.facultyName
                }
            ]
            if (this.userInfo.manageFaculty) {
                this.currentManageCollege = this.userInfo.manageFaculty.split(',')
                let manageFaculty = []
                this.allCollege.map(item => {
                    this.currentManageCollege.map(element => {
                        if (item.value === element) {
                            manageFaculty.push({
                                value: item.value,
                                label: item.label
                            })
                        }
                    })
                })
                if (manageFaculty.length > 0) {
                    this.options.collegeAcademyList = this.options.collegeAcademyList.concat(
                        manageFaculty
                    )
                }
            }
        }
        this.auths.some(item => {
            if (item.authCode === 'settingInternshipBase-revokeBtn') {
                // 撤销
                this.revokeBtn = true
            }
            if (item.authCode === 'settingInternshipBase-addBut') {
                // 新增
                this.addBut = true
            }
            if (item.authCode === 'settingInternshipBase-editBut') {
                // 编辑
                this.editBut = true
            }
            if (item.authCode === 'settingInternshipBase-detailsBut') {
                // 详情
                this.detailsBut = true
            }
            if (item.authCode === 'settingInternshipBase-deriveBut') {
                // 导出
                this.deriveBut = true
            }
            if (item.authCode === 'settingInternshipBase-leadBut') {
                // 导入
                this.leadBut = true
            }
            if (item.authCode === 'settingInternshipBase-auditBut') {
                // 审核
                this.auditBut = true
            }
            if (item.authCode === 'settingInternshipBase-removeBut') {
                // 删除
                this.removeBut = true
            }
            if (item.authCode === 'settingInternshipBase-batchReviewBut') {
                // 批量审核
                this.batchReviewBut = true
            }
            if (item.authCode === 'settingInternshipBase-startUsingBut') {
                // 启用
                this.startUsingBut = true
            }
            if (item.authCode === 'settingInternshipBase-blockUpBut') {
                // 停用
                this.blockUpBut = true
            }
        })
    },
    mounted() {},
    methods: {
        postRegistration(date) {
            graduateStudent.registration(date).then(res => {
                this.queryForm.pageNum_ = res.data.pageNum_
                this.queryForm.pageSize_ = res.data.pageSize_
                this.queryForm.total_ = res.data.total_
                this.dataList = res.data.list
            })
        },
        // 获取当前登录用户
        getCurrentRole() {
            graduateStudent.getCommonCurrentRole().then(res => {
                this.personas = res.data
                // "data":"管理员/教务员/导师/学生/基地管理员/实践专家/校外导师"
            })
        },
        getOptions() {
            // 筛选条件字典查询
            let data = {
                lang: this.$store.getters.language || 'cn',
                type: 'allChild',
                keys: [
                    'G_XBIE',
                    'JDJB',
                    'X_PYCC', // 培养层次
                    'X_PYLB', // 培养类别
                    'X_XWLX', // 学位类型
                    'X_XXXS', // 学习形式
                    'X_YX', // 学院
                    'G_ZY'
                ]
            }
            queryDic(data).then(res => {
                // this.options['majorList'].push({ code: '', name: '全部' })
                UTILS.fillSelect(
                    {
                        title: 'X_YX',
                        faculty: 'G_ZY'
                    },
                    res.data,
                    this.options
                )
            })
        },

        // 学院选择
        collegeChange(val) {
            this.queryForm.condition.majorList = []
            if (val.length > 0) {
                let collegeList = []
                collegeList.push(val)
                graduateStudent.getDegreeByCollege(collegeList).then(res => {
                    this.options.profession = res.data
                })
            } else {
                this.options.profession = []
            }
            this.queryForm.condition.collegeAcademyList = []
            if (val) {
                this.queryForm.condition.collegeAcademyList.push(val)
            } else {
                this.queryForm.condition.collegeAcademyList = []
            }
        },
        // 导师审核
        checkOutlines(row) {
            this.$router.push({
                path: '/registrationReviewCheck',
                query: {
                    dataInfo: row
                }
            })
        },
        // 基地审核
        checkOutlines2(row) {
            this.$router.push({
                path: '/registrationReviewCheckBase',
                query: {
                    dataInfo: row
                }
            })
            // let dataObj = {}
            // graduateStudent
            //     .regGetDetail(row.needsId)
            //     .then(res => {
            //         dataObj = res.data
            //     })
            //     .then(() => {
            //         graduateStudent.getregDetailAudit(row.actNo).then(res => {
            //             this.$router.push({
            //                 path: '/registrationReviewCheckBase',
            //                 query: {
            //                     data: dataObj,
            //                     list: res.data,
            //                     id: row.id
            //                 }
            //             })
            //         })
            //     })
        },
        // 查看详情
        view(row) {
            this.$router.push({
                path: '/registrationReviewDetails',
                query: {
                    dataInfo: row
                }
            })
            // let dataObjits = {}
            // graduateStudent.regGetDetail(row.needsId).then(res => {
            //     dataObjits = res.data
            // }).then(() => {
            //         graduateStudent.getregDetailAudit(row.actNo).then(res => {
            //             this.$router.push({
            //                 path: '/registrationReviewDetails',
            //                 query: {
            //                     data: dataObjits,
            //                     list: res.data,
            //                     id: row.id
            //                 }
            //             })
            //         })
            //     })
        },

        // 导出
        exportFile(command) {
            // 1、第一步：调该接口，获取key值以及msg中的文件名
            // 2、第二步：将key值放入接口传参
            // 3、第三步：传入path值以及name(msg中的文件名)值，下载文件
            let list = []
            let data = []
            let dataList = JSON.parse(JSON.stringify(this.multipleSelection))
            if (dataList.length > 0) {
                dataList.forEach(el => {
                    this.options.title.forEach(ele => {
                        if (el.faculty === ele.value) {
                            el.faculty = ele.label
                        }
                    })
                    this.options.faculty.forEach(ele => {
                        if (el.profession === ele.value) {
                            el.profession = ele.label
                        }
                    })
                    this.statusList.forEach(ele => {
                        if (el.status === ele.value) {
                            el.status = ele.label
                        }
                    })

                    el.workTime = el.workTimeStart + '/' + el.workTimeEnd
                    el.applyTime = el.applyTimeStart + '/' + el.applyTimeEnd
                })
            } else {
                dataList = []
            }
            let obj = {
                positionApplyExportDTOList: dataList,
                applySearchCondition: this.queryForm.condition
            }
            graduateStudent.exportRegistration(obj).then(() => {
                this.$message(this.$t('internship.successfully'))
            })
        },
        // 下载
        regDownload() {
            if (this.multipleSelection.length === 0) {
                this.$message(this.$t('请选择需要下载的文件'))
                return
            } else if (this.multipleSelection.length > 0) {
                let list = []
                let statusList = []
                this.multipleSelection.forEach(el => {
                    if (el.status != 1 && el.status != 2 && el.status != 4 && el.status != 5) {
                        list.push(el.id)
                        statusList.push(true)
                    } else {
                        statusList.push(false)
                    }
                })
                if (statusList.includes(false)) {
                    this.$message(this.$t('internship.pleaseDownloaded'))
                    return
                } else {
                    let ids = this.multipleSelection.map(item => item.id).join(',')
                    // graduateStudent.exportdownPlan(ids)
                    let domIframe = document.createElement('iframe')
                    domIframe.src = '/api/practiceservice/positionApply/downPlan?ids=' + ids
                    domIframe.style.display = 'none'
                    document.body.appendChild(domIframe)
                    this.$message.success(this.$t('下载成功'))
                }
            }
        },

        // 撤销
        deleteBaseAssessSettingRow(id) {
            graduateStudentApi
                .revokeRegistration({
                    id: id
                })
                .then(res => {
                    if (res.code === 200) {
                        this.$message.success(this.$t('撤销成功'))
                        this.onSubmit()
                    }
                })
        },
        deleteBaseAssessSet(row) {
            if (row.status === 1) {
                this.$confirm('是否确认撤销本次申请?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(_ => {
                    this.deleteBaseAssessSettingRow(row.id)
                })
            } else {
                this.deleteBaseAssessSettingRow(row.id)
            }
        },
        // 轮询直到获取key值的接口返回
        cycleToGetKey() {
            setTimeout(() => {
                let currentIds = []
                if (this.multipleSelection.length > 0) {
                    this.multipleSelection.forEach(element => {
                        currentIds.push(element.id)
                    })
                } else {
                    this.dataList.forEach(element => {
                        currentIds.push(element.id)
                    })
                }
                graduateStudent
                    .specialist({
                        templateName: this.queryForm.condition.department,
                        baseLevel: this.queryForm.condition.proTitle,
                        isEnabled: this.queryForm.condition.isEnabled,
                        name: this.queryForm.condition.name,
                        sex: this.queryForm.condition.sex,
                        // "category": this.queryForm.condition.category,
                        selectRowIds: currentIds
                    })
                    .then(res => {
                        if (res.success) {
                            this.$refs.downloadRef.close()
                            this.exportButton = false
                            this.normalDelayRequest(res.key, res.msg)
                        } else {
                            this.cycleToGetKey()
                        }
                    })
            }, 3000)
        },
        // 导出异步
        delayRequest(key, name) {
            setTimeout(() => {
                graduateStudent.downloadGetKey(key, name).then(res => {
                    this.exportResult = res.data
                    if (res.code == 200 && res.data.status) {
                        this.exportButton = false
                        let path =
                            '/api/practiceservice/export/file?path=' +
                            res.data.path +
                            '&name=' +
                            name
                        // window.open(path);
                        window.location.href = path
                        this.$message.success(this.$t('result.exportSuccessfully'))
                        this.$refs.downloadRef.close()
                    } else {
                        this.delayRequest(key, name)
                    }
                })
            }, 3000)
        },
        // Normal导出异步
        normalDelayRequest(key, name) {
            setTimeout(() => {
                graduateStudent.downloadGetKey(key).then(res => {
                    this.exportResult = res.data
                    if (res.code == 200 && res.data.status) {
                        this.exportButton = false
                        let path =
                            '/api/practiceservice/export/file?path=' +
                            res.data.path +
                            '&name=' +
                            name
                        // window.open(path);
                        window.location.href = path
                        this.$message.success(this.$t('result.exportSuccessfully'))
                        this.$refs.downloadRef.close()
                    } else {
                        this.delayRequest(key, name)
                    }
                })
            }, 3000)
        },

        // 搜索/筛选
        onSubmit() {
            this.queryForm.pageNum_ = 1
            this.postRegistration(this.queryForm)
        },

        // 批量审核
        batchReview() {
            if (this.multipleSelection.length > 0) {
                let list = []
                let isEnabled = []
                this.multipleSelection.forEach(el => {
                    if (el.status != 2 && el.status != 3 && el.actNo) {
                        list.push(el.id)
                        isEnabled.push(true)
                    } else {
                        isEnabled.push(false)
                    }
                })

                if (isEnabled.includes(false)) {
                    this.$message(this.$t('internship.pleaseCheck'))
                    return (this.dialogFormVisible = false)
                } else {
                    return (this.dialogFormVisible = true)
                }
            } else {
                return this.$message.warning(this.$t('internship.selectManipulate'))
            }
        },
        // 批量审核取消
        cancelClose() {
            this.dialogFormVisible = false
            this.form.content = ''
        },
        // 批量审核驳回
        reject() {
            if (this.form.content.indexOf('$') < 0) {
                if (this.form.content) {
                    let practiceIds = []
                    this.multipleSelection.forEach(el => {
                        practiceIds.push({
                            content: this.form.content,
                            no: el.actNo
                        })
                    })
                    graduateStudent.internshipRefuse(practiceIds).then(data => {
                        this.$message({
                            type: 'success',
                            message: this.$t('identificationToDoList.SuccessfulOperation')
                        })
                        this.queryForm.pageNum_ = 1
                        this.queryForm.condition.collegeAcademyList = []
                        if (this.queryForm.condition.collegeAcademy) {
                            this.queryForm.condition.collegeAcademyList.push(
                                this.queryForm.condition.collegeAcademy
                            )
                        } else {
                            this.queryForm.condition.collegeAcademyList = []
                        }
                        this.postRegistration(this.queryForm)
                        this.dialogFormVisible = false
                    })
                } else {
                    this.$message({
                        type: 'error',
                        message: this.$t('myExamine.reviewComments')
                    })
                }
            } else {
                this.$message({
                    type: 'error',
                    message: this.$t('identificationToDoList.cannotContain')
                })
            }
        },
        // 批量审核通过
        pass() {
            if (this.form.content.indexOf('$') < 0) {
                let practiceIds = []
                this.multipleSelection.forEach(el => {
                    practiceIds.push({
                        content: this.form.content,
                        no: el.actNo
                    })
                })
                graduateStudent.internshipAgree(practiceIds).then(data => {
                    this.$message({
                        type: 'success',
                        message: this.$t('identificationToDoList.SuccessfulOperation')
                    })
                    this.queryForm.pageNum_ = 1
                    this.queryForm.condition.collegeAcademyList = []
                    if (this.queryForm.condition.collegeAcademy) {
                        this.queryForm.condition.collegeAcademyList.push(
                            this.queryForm.condition.collegeAcademy
                        )
                    } else {
                        this.queryForm.condition.collegeAcademyList = []
                    }
                    this.postRegistration(this.queryForm)
                    this.dialogFormVisible = false
                })
            } else {
                this.$message({
                    type: 'error',
                    message: this.$t('identificationToDoList.cannotContain')
                })
            }
        },
        // 取消
        changeClose(param) {
            this.addflag = param
        },
        // 取消
        beforeClose(param) {
            this.$refs.addform.cancelDialog()
        },
        tableClose() {
            this.tableFlag = false
        },

        addCancel(data) {
            this.addflag = data
        },

        handleSelectionChange(val) {
            this.multipleSelection = val
        },

        // 关闭弹框
        changeProp() {
            this.addflag = false
        },
        // 查看考核指标表
        indicatorsList() {},
        // 重置
        reset() {
            for (let key in this.queryForm.condition) {
                if (key === 'collegeAcademyList') {
                    this.queryForm.condition.collegeAcademyList = []
                } else if (key === 'majorList') {
                    this.queryForm.condition.majorList = []
                } else {
                    this.queryForm.condition[key] = ''
                }
            }
            this.options.profession = []
            this.queryForm.pageNum_ = 1
            this.postRegistration(this.queryForm)
        },
        // 保存
        conserve() {
            this.addflag = false
        },

        diaCancel() {
            this.$refs['copyTime'].resetFields()
            this.copyDialog = false
        },

        handleSizeChange(val) {
            this.queryForm.pageSize_ = val
            this.queryForm.pageNum_ = 1
            this.queryForm.condition.collegeAcademyList = []
            if (this.queryForm.condition.collegeAcademy) {
                this.queryForm.condition.collegeAcademyList.push(
                    this.queryForm.condition.collegeAcademy
                )
            } else {
                this.queryForm.condition.collegeAcademyList = []
            }
            this.postRegistration(this.queryForm)
        },
        handleCurrentChange(val) {
            this.queryForm.pageNum_ = val
            this.queryForm.condition.collegeAcademyList = []
            if (this.queryForm.condition.collegeAcademy) {
                this.queryForm.condition.collegeAcademyList.push(
                    this.queryForm.condition.collegeAcademy
                )
            } else {
                this.queryForm.condition.collegeAcademyList = []
            }
            this.postRegistration(this.queryForm)
        }
    }
}
</script>
<style lang="scss" scoped>
.is-enabled-container ::v-deep {
    .el-button {
        cursor: auto;
    }
    .el-button--danger {
        padding: 9px 15px;
        min-width: 0;
    }
}
.condition-title {
    color: #2b3b4e;
    font-size: 18px;
    line-height: 24px;
    font-weight: bold;
}
.edu-page-title {
    span {
        line-height: 24px;
        display: inline-block;
        padding-right: 10px;
        font-size: 18px;
        font-weight: bold;
        color: #2b3b4e;
    }
}
.sub-title {
    margin: 16px 0;
    font-size: 16px;
    color: #000020;
    letter-spacing: 0;
}
.form-item {
    width: 312px;
    height: 32px;
    float: left;
    margin: 0px 10px;
}
.inputBox {
    width: 240px !important;
    height: 32px !important;
}
.atooltip {
    background: beige;
    border: black;
}
</style>
